<?php
declare (strict_types = 1);

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;
class GmDicts extends Model
{
    use SoftDelete;
     protected $deleteTime = "delete_time";
    // 获取列表
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');
        
               //按类型名称查找
               if ($typename = input("typename")) {
                   $where[] = ["typename", "like", "%" . $typename . "%"];
               }
               //按字典名称查找
               if ($name = input("name")) {
                   $where[] = ["name", "like", "%" . $name . "%"];
               }
               //按标识查找
               if ($tag = input("tag")) {
                   $where[] = ["tag", "like", "%" . $tag . "%"];
               }
               //按字典值查找
               if ($dvalue = input("dvalue")) {
                   $where[] = ["dvalue", "like", "%" . $dvalue . "%"];
               }
        $list = self::order('id','desc')->where($where)->paginate($limit);
        return ['code'=>0,'data'=>$list->items(),'extend'=>['count' => $list->total(), 'limit' => $limit]];
    }


    public static function getDicValue()
    {
        return self::order('id')->field('tag,dvalue')->select(); // 直接返回结果数组，不要包装在 ['code'=>0,'data'=>...] 中
    }
}
